package com.twu.biblioteca;


public class Login{

    private User[] users ={
            new User("111-1111", "passw0rd", "Mr Admin", "admin@company", 987654321),
            new User("111-1112", "p@ssword", "Ms Librarian", "librarian@company", 123456789),
            new User("111-1113", "pa$$word", "Mr User", "user@company", 11223344)
    };
    private static Login instance = null;

    public static Login getInstance() {
        if(instance == null) {
            instance = new Login();
        }
        return instance;
    }

    public Boolean checkLogin(String username, String password) {
        for(User user : users) {
            if(user.getUsername().equals(username) && user.getPassword().equals(password)) {
                return true;
            }
        }
        return false;
    }

    public String getUserDetails(String username) {
        for(User user : users) {
            if(user.getUsername().equals(username)) {
                return user.getFormattedDetails();
            }
        }
        return null;
    }
}
